

namespace DtoDecorator {
    export type ApiParamsRegExp = { regexp: string, errorMsg: string };
    export type ApiParamsOptions = { required?: boolean, rule?: ApiParamsRegExp | ApiParamsRegExp[] }

    export type ApiParamsType = "string" | "bool" | "double" | "int" | { type: "list", prop: "string" | "bool" | "double" | "int" | Function } | { type: "object" | "enum", prop: Function };

    export const params: Record<string, Record<string, { desc: string, name: string, type: ApiParamsType, options: ApiParamsOptions }>> = {};


    export const ApiModel = () => {
        return function (_target: any) {

        }
    }

    export function ApiParams(desc: string, type: ApiParamsType, options?: ApiParamsOptions) {
        options = { required: true, ...(options || {}) };
        return function (_target: any, _attr: any) {
            params[_target.constructor.name] = params[_target.constructor.name] ?? {};
            params[_target.constructor.name][_attr] = { desc, type, name: _attr, options: options! };
        }
    }
}

export default DtoDecorator;